<template>
	<view v-if="show">
		<view class="tabbar-back">

		</view>
		<view class="tabbar-box">
			<view class="item" @tap="to_page(i.pagePath)" v-for="i,j in list" :key="i.pagePath">
				<view class="top">
					<image class="image" :class="{'image-center':i.pagePath == '/pages/issue/index'}"
						v-if="selectPath == i.pagePath" :src="i.selectedIconPath" mode="widthFix"></image>
					<image class="image" :class="{'image-center':i.pagePath == '/pages/issue/index'}" v-else
						:src="i.iconPath" mode="widthFix"></image>
				</view>
				<view class="bottom" :class="{'bottom-select':selectPath == i.pagePath}" v-if="i.text">
					{{i.text}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "tabbar",
		mounted() {
			uni.hideTabBar({
				success: () => {
					this.show = true;
				}
			});
			let path = getCurrentPages();
			path = path[0].$page.fullPath, "path";
			this.selectPath = path;
		},
		data() {
			return {
				show: false,
				selectPath: "/pages/index/index",
				"list": [{
						"pagePath": "/pages/index/index",
						"text": "首页",
						"iconPath": "/static/img/sho0uy0e.png",
						"selectedIconPath": "/static/img/sho0uye.png"
					},

					{
						"pagePath": "/pages/dynami/index",
						"text": "动态",
						"iconPath": "/static/img/faxian.png",
						"selectedIconPath": "/static/img/faxian0.png"
					},
					{
						"pagePath": "/pages/issue/index",
						"iconPath": "/static/img/fabsu.png",
						"selectedIconPath": "/static/img/fabsu.png"
					},
					{
						"pagePath": "/pages/message/index",
						"text": "消息",
						"iconPath": "/static/img/xiaoxi2.png",
						"selectedIconPath": "/static/img/xiaoxi002.png"
					},
					{
						"pagePath": "/pages/my/index",
						"text": "我的",
						"iconPath": "/static/img/weibiaoti3.png",
						"selectedIconPath": "/static/img/weibiaot1i3.png"
					}
				]
			};
		},
		methods: {
			to_page(path) {
				if (path == '/pages/issue/index') {
					uni.navigateTo({
						url:path
					})
					return
				}
				uni.switchTab({
					url: path
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "./tabbar.scss";
</style>
